/**
 *
 */
import Util;
import OpenApi;
import OpenApiUtil;
import EndpointUtil;

extends OpenApi;


init(config: OpenApi.Config){
  super(config);
  @endpointRule = '';
  
  checkConfig(config);
  @endpoint = getEndpoint('eduinterpreting', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}

function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
  if (!Util.empty(endpoint)) {
    return endpoint;
  }
  
  if (!Util.isUnset(endpointMap) && !Util.empty(endpointMap[regionId])) {
    return endpointMap[regionId];
  }
  return EndpointUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}

model RecognizeAudioRequest {
  audioFileUrl?: string(name='AudioFileUrl', description='This parameter is required.', example='http://xx.com/abc.mp3'),
  callbackUrl?: string(name='CallbackUrl', example='https://abc.edu.org.cn/en/callback'),
  enableCallBack?: boolean(name='EnableCallBack', description='This parameter is required.', example='true'),
  outerBizId?: string(name='OuterBizId', description='This parameter is required.', example='433c1361-0f6e-48fc-ad51'),
}

model RecognizeAudioResponseBody = {
  itemList?: [ 
    {
      beginTime?: string(name='BeginTime', example='0'),
      endTime?: string(name='EndTime', example='1230'),
      text?: string(name='Text', example='How are you'),
    }
  ](name='ItemList'),
  requestId?: string(name='RequestId', example='38CD0881-BC7B-5ADB-A3EB-FF813927D09A'),
  taskId?: string(name='TaskId', example='3ab5c082-2c0e-4f39-b12f-057dd5e373ff'),
}

model RecognizeAudioResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: RecognizeAudioResponseBody(name='body'),
}

/**
 * @summary 英语口译语音文件识别成英文内容
 *
 * @param request RecognizeAudioRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return RecognizeAudioResponse
 */
async function recognizeAudioWithOptions(request: RecognizeAudioRequest, runtime: Util.RuntimeOptions): RecognizeAudioResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.enableCallBack)) {
    query['EnableCallBack'] = request.enableCallBack;
  }
  var body : map[string]any = {};
  if (!Util.isUnset(request.audioFileUrl)) {
    body['AudioFileUrl'] = request.audioFileUrl;
  }
  if (!Util.isUnset(request.callbackUrl)) {
    body['CallbackUrl'] = request.callbackUrl;
  }
  if (!Util.isUnset(request.outerBizId)) {
    body['OuterBizId'] = request.outerBizId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'RecognizeAudio',
    version = '2024-08-28',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 英语口译语音文件识别成英文内容
 *
 * @param request RecognizeAudioRequest
 * @return RecognizeAudioResponse
 */
async function recognizeAudio(request: RecognizeAudioRequest): RecognizeAudioResponse {
  var runtime = new Util.RuntimeOptions{};
  return recognizeAudioWithOptions(request, runtime);
}

model SubmitEvaluationTaskRequest {
  audioUrl?: string(name='AudioUrl', description='This parameter is required.', example='http://xx.com/abc.mp3'),
  callbackUrl?: string(name='CallbackUrl', description='This parameter is required.', example='https://abc.edu.org.cn/en/callback'),
  materialText?: string(name='MaterialText', description='This parameter is required.', example='As flame of fire we gather, as skyful of stars we scatter.'),
  outerBizId?: string(name='OuterBizId', description='This parameter is required.', example='433c1361-0f6e-48fc-ad51'),
  suggestedAnswer?: string(name='SuggestedAnswer', description='This parameter is required.'),
  text?: string(name='Text', description='This parameter is required.'),
  type?: string(name='Type', description='This parameter is required.', example='EN_TO_ZH'),
}

model SubmitEvaluationTaskResponseBody = {
  requestId?: string(name='RequestId', example='BA3BB7D0-E098-5F0C-AF25-0BEFAEE7D1F0'),
  taskId?: string(name='TaskId', example='8fb75c55-98b5-4b82-ae67-5dbb9a0646cc'),
}

model SubmitEvaluationTaskResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: SubmitEvaluationTaskResponseBody(name='body'),
}

/**
 * @summary 口译评测任务
 *
 * @param request SubmitEvaluationTaskRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return SubmitEvaluationTaskResponse
 */
async function submitEvaluationTaskWithOptions(request: SubmitEvaluationTaskRequest, runtime: Util.RuntimeOptions): SubmitEvaluationTaskResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.audioUrl)) {
    body['AudioUrl'] = request.audioUrl;
  }
  if (!Util.isUnset(request.callbackUrl)) {
    body['CallbackUrl'] = request.callbackUrl;
  }
  if (!Util.isUnset(request.materialText)) {
    body['MaterialText'] = request.materialText;
  }
  if (!Util.isUnset(request.outerBizId)) {
    body['OuterBizId'] = request.outerBizId;
  }
  if (!Util.isUnset(request.suggestedAnswer)) {
    body['SuggestedAnswer'] = request.suggestedAnswer;
  }
  if (!Util.isUnset(request.text)) {
    body['Text'] = request.text;
  }
  if (!Util.isUnset(request.type)) {
    body['Type'] = request.type;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'SubmitEvaluationTask',
    version = '2024-08-28',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 口译评测任务
 *
 * @param request SubmitEvaluationTaskRequest
 * @return SubmitEvaluationTaskResponse
 */
async function submitEvaluationTask(request: SubmitEvaluationTaskRequest): SubmitEvaluationTaskResponse {
  var runtime = new Util.RuntimeOptions{};
  return submitEvaluationTaskWithOptions(request, runtime);
}

